import java.io.IOException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ZhongJinTao
 * Date: 2024-03-14
 * Time: 23:09
 */
public class TcpDictServer extends TcpEchoServer{
    HashMap<String, String> hashMap = new HashMap<>();
    public TcpDictServer(int serverPort) throws IOException {
        super(serverPort);
        hashMap.put("cat", "小猫");
        hashMap.put("dog", "小狗");
        hashMap.put("chicken", "坤坤");
    }

    @Override
    public String process(String request) {
        return hashMap.getOrDefault(request, "没有你要找的单词");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer tcpDictServer = new TcpDictServer(9090);
        tcpDictServer.start();
    }
}
